// 得到url 参数并且赋值

import $store from './../../store';

async function getLinkId() {
  //  如果有值则赋值且本地存储一下,如果没有则去本地获取赋值空值 
  //linkId
  let linkId = await getParameter('linkId');
  if (linkId) {
    $store.state.buyTicket.linkId = linkId;
    sessionStorage.setItem('linkIdUcan', linkId);
  } else {
    // $store.state.buyTicket.linkId = sessionStorage.getItem('linkIdUcan') || '' || '6c206bb66f508'; //写死一个测试
    $store.state.buyTicket.linkId = sessionStorage.getItem('linkIdUcan') || '';
  }


  return new Promise((resolve) => {
    resolve('ok');
  });
}

function getParameter(parameter) {
  return new Promise((resolve) => {
    resolve(decodeURIComponent((new RegExp('[?|&]' + parameter + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || '');
  });

}



export {
  getLinkId
};
